import { takeEvery, put } from "redux-saga/effects";
import axios from 'axios'
import { signup, signup_fail, signup_success } from "../actions/signup";
import { API } from '../../config'

function* handleSignup(action){
  console.log(action)
  try {
    yield axios.post(`${API}/signup`, action.payload)
    yield put(signup_success())
  } catch (ex) {
    yield put(signup_fail({message: ex.response.data.error}))
  }
}
export default function* signupSaga() {
  yield takeEvery(signup, handleSignup)
}
